<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // promise对象是一种异步编程的解决方案
        // let p1 = new Promise((resolve,reject)=>{
        //     //resolve,reject是两个方法
        //     //resolve是成功的回调
        //     //reject是失败的回调
        //     //必须调用其中一个才能执行下去
        // }).then((x)=>{
        //     //调用resolve
        // }).catch(()=>{
        //     //调用reject
        // }).finally(()=>{
        //     //成功失败都会回调
        // })
        // pending 待定状态
        //fulfilled 成功状态
        //rejected 失败状态
        let p1 = new Promise((resolve,reject)=>{
            // resolve()
            // reject()
            setTimeout(() => {
                console.log("00000")
                let id = 100;
                reject(id)
            },5000);
        }).then((id)=>{
            setTimeout(() => {
                console.log("11")
                console.log(id,'id')
            }, 800);
        }).catch((id)=>{
            console.log('2222',id,'id')
        })
    </script>
</body>
</html>